﻿using System;
using System.Collections.Generic;
using System.Text;

using System.Windows.Forms;
using System.Drawing;

namespace LiBLaB
{
    namespace GUI
    {
        public class GUI
        {
            delegate void AddToGUIDelegate(Control c, object data);
            private AddToGUIDelegate addDataDelgate;

            public GUI()
            {
                addDataDelgate = new AddToGUIDelegate(_AddToGUI);
            }
            public void AddToGUI(Form mainForm, Control c, object data)
            {
                mainForm.Invoke(addDataDelgate, c, data);
            }

            private void _AddToGUI(Control c, object data)
            {
                if (c is TextBoxBase)
                {
                    TextBoxBase t = (TextBoxBase)c;
                    t.Text = (string)data;
                }
                else if (c is ListBox)
                {
                    ListBox l = (ListBox)c;
                    l.Items.Add(data);
                }
                else if (c is PictureBox)
                {
                    PictureBox pic = (PictureBox)c;
                    pic.Image = (Image)data;
                }
            }
        }
    }
}